<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>防抖</title>
</head>
<body>
<label>
    <input type="text">
</label>
<script>

    document.querySelector("input").addEventListener('input',debounce(function () {
        console.log("asd")
    },1000))
function debounce(fn,time) {
    let timer = null
    return function (params){
        clearTimeout(timer)
        timer = null

        timer = setTimeout(()=>{
            fn.apply(this,params)
        },time)

    }

}



</script>
</body>
</html>